package org.wangblue.index;

import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;
import org.wangblue.common.Client;

import java.io.IOException;

/**
 * @Description: 查询索引
 * @Author: WangBlue
 * @Create: 2024-10-22 15:40
 * @Version: 1.0
 **/

public class SearchIndex {
    private static final String INDEX_NAME = "user";
    public static void main(String[] args) throws IOException {
        // 1. 创建客户端对象
        RestHighLevelClient client = Client.getClient();

        // 2. 查询索引 - 请求对象
        GetIndexRequest request = new GetIndexRequest(INDEX_NAME);

        // 3. 发送请求, 获取响应
        GetIndexResponse response = client.indices().get(request, RequestOptions.DEFAULT);

        System.out.println("aliases:"+response.getAliases());
        System.out.println("mappings:"+response.getMappings());
        System.out.println("settings:"+response.getSettings());

        // 4. 关闭链接
        client.close();
    }
}
